#include "UsbSwitcher.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/system_properties.h>
#include <android/log.h>

#define PROPERTY_VALUE_MAX 92
static char board_platform[PROPERTY_VALUE_MAX] = { 0 };


int UsbSwitcher_Device()
{
	__system_property_get("ro.board.platform", board_platform);
	if (strcmp(board_platform, "msm8953") == 0) {
		//sd450
		system("echo \"peripheral\" > /sys/devices/platform/soc/7000000.ssusb/mode"); //device
	}else if (strcmp(board_platform, "mt8163") == 0) {
		//mtk mt8163
		//echo device > /sys/devices/platform/mt_usb/usb_mode
		system("echo \"device\" > /sys/devices/platform/mt_usb/usb_mode"); //device
	}else if (strcmp(board_platform, "lahaina") == 0) {
		//qualcomm 6490
		system("echo \"peripheral\" > /sys/devices/platform/soc/a600000.ssusb/mode"); //device
	}else{
		system("echo \"peripheral\" > /sys/devices/platform/soc/4e00000.ssusb/mode"); //device
	}

	return 0;
}

int UsbSwitcher_Host()
{
	__system_property_get("ro.board.platform", board_platform);
	if (strcmp(board_platform, "msm8953") == 0) {
		//sd450
		system("echo \"host\" > /sys/devices/platform/soc/7000000.ssusb/mode"); //host
	}else if (strcmp(board_platform, "mt8163") == 0) {
		//mtk mt8163
		system("echo \"host\" > /sys/devices/platform/mt_usb/usb_mode"); //host
	}else if (strcmp(board_platform, "lahaina") == 0) {
		//qualcomm 6490
		system("echo \"host\" > /sys/devices/platform/soc/a600000.ssusb/mode"); //host
	}else{
		system("echo \"host\" > /sys/devices/platform/soc/4e00000.ssusb/mode"); //host
	}

	return 0;
}

